package com.youdianstar.app.entity

import com.google.android.gms.maps.model.LatLng
import com.google.maps.android.clustering.ClusterItem


/**
 * File: BranchInfo
 * Author: 82149 Create: 2021/9/29 11:42
 * Changes (from 2021/9/29)
 * --------------------------------------------------
 * description: 网点信息,列表/详情
 * ---------------------------------------------------
 *
 */
data class BranchInfo(
    val id: Int, val branchName: String, val address: String,val addressMap:String?,
    val distance: Double,
    //维度
    val lat: Double,
    //经度
    val lng: Double,
    val logo: String?, val images: String?, val website: String?, val landlinePhone: String?,
    val rent: Int, val recovery: Int, val isBusiness: Boolean, val openTime: String,
    val billing: BillingPlan?
) : ClusterItem {

    override fun getPosition(): LatLng {
        android.util.Log.d("BranchInfo", "getPosition: lat=$lat, lng=$lng")
        return LatLng(lat, lng) // LatLng构造参数顺序是 (latitude, longitude)
    }

    override fun getTitle(): String {
        return ""
    }

    override fun getSnippet(): String {
        return ""
    }

    override fun getZIndex(): Float? {
        return null
    }

    override fun equals(other: Any?): Boolean {
        if (this === other) return true
        if (javaClass != other?.javaClass) return false

        other as BranchInfo

        if (id != other.id) return false
        if (branchName != other.branchName) return false
        if (address != other.address) return false
        if (addressMap != other.addressMap) return false
        if (distance != other.distance) return false
        if (lat != other.lat) return false
        if (lng != other.lng) return false
        if (logo != other.logo) return false
        if (images != other.images) return false
        if (website != other.website) return false
        if (landlinePhone != other.landlinePhone) return false

        if (rent != other.rent) return false
        if (recovery != other.recovery) return false
        if (isBusiness != other.isBusiness) return false
        if (openTime != other.openTime) return false
        if (billing != other.billing) return false
        return true
    }

    override fun hashCode(): Int {
        var result = id.hashCode()
        if (branchName.isNotEmpty()) {
            result = 17 * result + branchName.hashCode()
        }
        if (address.isNotEmpty()) {
            result = 17 * result + address.hashCode()
        }
        if (addressMap?.isNotEmpty() == true) {
            result = 17 * result + addressMap.hashCode()
        }
        result = 17 * result + distance.hashCode()
        result = 17 * result + lat.hashCode()
        result = 17 * result + lng.hashCode()

        if (logo?.isNotEmpty() == true) {
            result = 17 * result + logo.hashCode()
        }
        if (images?.isNotEmpty() == true) {
            result = 17 * result + images.hashCode()
        }
        if (website?.isNotEmpty() == true) {
            result = 17 * result + website.hashCode()
        }
        if (landlinePhone?.isNotEmpty() == true) {
            result = 17 * result + landlinePhone.hashCode()
        }

        result = 17 * result + rent.hashCode()
        result = 17 * result + recovery.hashCode()
        result = 17 * result + isBusiness.hashCode()
        if (openTime.isNotEmpty()) {
            result = 17 * result + openTime.hashCode()
        }
        if (null!=billing){
            result = 17 * result + billing.hashCode()
        }
        return result
    }
}
